package com.wg.web_app.controller;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.wg.web_app.service.NumberService;

@SpringBootApplication
@Controller
public class NumberController {
	
	@RequestMapping(value = "/del_number", method = RequestMethod.DELETE)
	@ResponseBody
	public String delNumber(@RequestParam("number_id") int nid) {
		NumberService ns = new NumberService();
		return new Gson().toJson(ns.del(nid));
	}
	
	@RequestMapping(value = "/edit_number", method = RequestMethod.PUT)
	@ResponseBody
	public String editNumber(@RequestParam("number_id") int nid,@RequestParam("tag") String tag,@RequestParam("number") String number) {
		NumberService ns = new NumberService();
		return new Gson().toJson(ns.update(nid,tag,number));
	}
}
